home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Games 1996 July
/
Amiga Games 1996 #7.iso
/
archive
/
userbox
/
publicdomain
/
hildu.lha
/
HiL-Du
/
hilsort.doc
< prev
next >
Wrap
Text File
|
1996-03-27
|
1KB
|
46 lines
TABLE OF CONTENTS
hil.lib/QSort
hil.lib/QSort hil.lib/QSort
NAME
QSort -- performs a quicksort operation.
SYNOPSIS
success = QSort( array, items, cmpfunc );
D0 A0 D0 A1
BOOL QSort( APTR *array, ULONG items, struct Hook *cmpfunc );
FUNCTION
This function sorts the given array using an interactive quicksort
algorythm, no stack problems will occur. A buffer will be allocated
to hold the stack information. If this allocation fails, this
function will fail. The hook will be used for comparison, and should
return something like this: <0 e1 < e2 0 e1 == e2 >0 e1 > e2
INPUTS
array - Array to be sorted
items - Number of elements in array
cmpfunc - Hook to be used for comparison. The hook will be called
with the following arguments: A0 struct Hook* - pointer to
the hook itself A1 APTR - first pointer in the array for
comparison A2 APTR - second pointer in the array for
comparison
RESULT
success (D0) - success/failure indicator.
EXAMPLE
Hook function for strings:
LONG __saveds __asm cmpfunc(
register __a0 struct Hook *hook,
register __a1 STRPTR e1,
register __a2 STRPTR e2)
{
return strcmp(e1, e2);
}